import Vuex from 'vuex'
import Vue from 'vue'
import  axios from 'axios'
Vue.use(Vuex)

const store = new Vuex.Store({
  state:{
    isLogin:false,      //登录状态
    phone:'',            //手机号
    comic:[],             //漫画
    collect:[],         //以收藏
    cache:[],           //已下载
    states:false      //请求状态
  },
  mutations:{
    getdata(state,res){
      state.comic = res.data.comic
      state.states = true
      // console.log(state.comic);
      console.log(state.states);
    }
  },
  actions: {
    getdata(context) {    //数据请求
      axios.get('../../static/json/comic.json')
        .then(res => {
          context.commit("getdata", res);
        })
        .catch((error) => {
          console.log(error)
        })
    }
  }
})
export default store
